/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jsrpc.core;

import java.util.Hashtable;
import org.jsrpc.bridge.Protocal;
import org.jsrpc.vo.CallMethod;
import org.jsrpc.vo.Parameter;

/**
 *
 * @author neo
 */
public class Adapter {


    public CallMethod transformerCallMethod(Hashtable<String,String> table, Protocal protocal) {
        CallMethod callMethod = new CallMethod();
        callMethod.setClassName(table.get(Key.JAVA_CLASS));
        callMethod.setName(table.get(Key.METHOD_NAME));
        int length = Integer.parseInt(table.get(Key.PARAM_LENGTH));
        //System.out.println("length["+ length +"]");
        //System.out.println("V["+ table.get(Key.PARAM_AT+"0") +"]");
        for (int i = 0; i < length; i++) {
            String paramValue = table.get(Key.PARAM_AT+i);
            //System.out.println("Value["+ paramValue +"]");
            Hashtable<String,String> tbl = protocal.getTable(paramValue);
            String sclass = tbl.get(Key.JAVA_CLASS);
            String value = tbl.get(Key.PARAM_VALUE);
            //System.out.println("Value2["+ value +"]");
            callMethod.addParams(new Parameter(sclass, value));
        }
        return callMethod;
    }
}
